//
//  RJWarningFirstDay.m
//  AirQuality
//
//  Created by Po on 15/4/9.
//  Copyright (c) 2015年 Po. All rights reserved.
//

#import "RJWarningFirstDay.h"
#import "RJWarningFirstPicker.h"
@interface RJWarningFirstDay () <WarningFirstPickerDelegate>
@property (weak, nonatomic) IBOutlet UIButton *selectButton;
@property (retain, nonatomic) RJWarningFirstPicker * pickeView;

@end

@implementation RJWarningFirstDay

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray * array = [[NSBundle mainBundle] loadNibNamed:@"RJWarningFirstDay" owner:self options:nil];
        UIView * view = array[0];
        [view setFrame:self.bounds];
        [view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"alphaBack"]]];
        [self addSubview:view];
        _selectBackColor = GetRGBColor(218, 145, 145, 1);
        
        NSArray * labelArray = @[_timeLabel, _value48,_value72,_value96,_selectLabel,_modelWarningLabel,_hour48Label,_mainPollutionTittleLabel,_hour72Label,_hour96Label,_mainPollutionTittleLabel];
        for (UILabel * label  in labelArray) {
            [label setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"homeTableCellBack"]]];
        }

    }
    return self;
}

- (RJWarningFirstPicker *)getPickerView
{
    if (!_pickeView) {
        _pickeView = [[RJWarningFirstPicker alloc] initWithFrame:ScreenBounds data:@[@"PM2.5",@"O3",@"SO2",@"NO2",@"CO",@"PM10",@"无"]];
        [_pickeView setDelegate:self];
    }
    return _pickeView;
}

- (IBAction)pressButton:(id)sender {
    if ([RJUserData defaultRJUserData].isAudit) {
        return;
    }
    [sysWindow addSubview:[self getPickerView]];
}

#pragma mark - WarningFirstPicker
- (void)WarningFirstPicker:(RJWarningFirstPicker *)picker selectString:(NSArray *)strings
{
    NSMutableString * typeString = [[NSMutableString alloc] init];
    //判断为空
    if ([strings count] == 0) {
        [_selectLabel setText:@"点击选择"];
        [_selectLabel setBackgroundColor:_selectBackColor];
        return;
    }
    
    //更新数据
    for (NSString * string in strings) {
        if ([typeString isEqualToString:@""]) {
            [typeString appendFormat:@"%@",[RJTools getQulityString:string]];
            continue;
        }
        [typeString appendFormat:@",%@",[RJTools getQulityString:string]];
    }
    [_selectLabel setText:typeString];
    [_selectLabel setBackgroundColor:[UIColor clearColor]];
}
@end
